<script setup lang="ts">
import { ref,reactive, onMounted } from 'vue';
import axios from 'axios';
let tableData = ref<any>([])
let dataparam = reactive({
    "api_name": "daily",
    "token": "4f6fd4be246e9a3fa5c37184b27da7c832e961a746360dfbc217584b",
    "params": {
        "ts_code": "600230.SH",
        "start_date": "20240302",
        "end_date": "20240402"
    },
    "fields": "ts_code,trade_date,open,high,low"
})

const getgp = () => {
    axios.post('http://api.tushare.pro', dataparam).then((res: any) => {
        res.data.data.items.forEach((item: any) => {
            tableData.value.push({
                "ts_code": item[0],
                "trade_date": item[1],
                "open": item[2],
                "high": item[3],
                "low": item[4]
            })
        }) 
    }).catch((err: any) => {
        console.log(err)
    })
}
onMounted(() => {
    getgp();
})
</script>

<template>
    <el-table :data="tableData" style="width: 100%">
                    <el-table-column type="index" label="序号"></el-table-column>
                    <el-table-column prop="ts_code" label="股票代码"></el-table-column>
                    <el-table-column prop="trade_date" label="交易日期"></el-table-column>
                    <el-table-column prop="open" label="开盘价"></el-table-column>
                    <el-table-column prop="high" label="最高价"></el-table-column>
                    <el-table-column prop="low" label="最低价"></el-table-column>
                </el-table>
</template>

<style scoped lang="scss">
.form {
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
</style>